/**
 * 
 */
package com.hexacta.hrs.domain.staffing.relationship.fixture;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;

import org.vectrics.employee.Employee;
import org.vectrics.recruiter.job.JobFunction;
import org.vectrics.user.Person;

import com.hexacta.hrs.domain.staffing.Project;
import com.hexacta.hrs.domain.staffing.Requirement;
import com.hexacta.hrs.domain.staffing.assignment.AssignmentType;
import com.hexacta.hrs.domain.staffing.assignment.EmployeeAssignment;
import com.hexacta.hrs.domain.staffing.relationship.RequirementAssignmentRelationship;

/**
 * @author gvilla
 * 
 */
public class RequirementAssignmentRelationshipFixture {

    public static RequirementAssignmentRelationship createFullRAR() {
        RequirementAssignmentRelationship rar = new RequirementAssignmentRelationship();

        String comment = "aComment";
        Employee employee = new Employee();
        employee.setPerson(new Person());
        employee.getPerson().setFirstName("aPerson");
        Calendar endDate = new GregorianCalendar(2012, 6, 7);
        Calendar startDate = new GregorianCalendar(2011, 6, 7);
        double assignmentPorcentage = 80.0;
        Project project = new Project();
        project.setName("aProject");
        Long requirementId = (long) 54;
        JobFunction role = new JobFunction();
        role.setCode("aRole");
        role.setDescription("aDescription");
        boolean tentative = true;

        rar.setComments(comment);
        rar.setEmployee(employee);
        rar.setEndDate(endDate);
        rar.setPorcentage(assignmentPorcentage);
        rar.setProject(project);
        rar.setRequirementId(requirementId);
        rar.setRole(role);
        rar.setStartDate(startDate);
        rar.setTentative(tentative);

        return rar;
    }

    public static EmployeeAssignment createFullEA() {

        EmployeeAssignment ea = new EmployeeAssignment();

        JobFunction assignedRole = new JobFunction();
        assignedRole.setCode("aCode");
        assignedRole.setDescription("aRole");
        ea.setAssignedRole(assignedRole);
        double assignmentPorcentage = 100;
        ea.setAssignmentPorcentage(assignmentPorcentage);
        AssignmentType assignmentType = AssignmentType.AddOnAvailable;
        ea.setAssignmentType(assignmentType);
        String comments = "aComment";
        ea.setComments(comments);
        Employee employee = new Employee();
        employee.setPerson(new Person());
        employee.getPerson().setFirstName("aPerson");
        ea.setEmployee(employee);
        Calendar endDate = new GregorianCalendar(2012, 6, 6);
        ea.setEndDate(endDate);
        Long id = (long) 666;
        ea.setId(id);
        Project project = new Project();
        project.setName("aProject");
        ea.setProject(project);
        Calendar startDate = new GregorianCalendar(2011, 6, 6);
        ea.setStartDate(startDate);
        boolean tentative = true;
        ea.setTentative(tentative);

        return ea;
    }

    public static Requirement createFullRequirement() {
        Requirement req = new Requirement();

        double assignmentPorcentage = 80.0;
        req.setAssignmentPorcentage(assignmentPorcentage);
        Calendar endDate = new GregorianCalendar(2012, 6, 6);
        req.setEndDate(endDate);
        Long id = (long) 666;
        req.setId(id);
        JobFunction requiredRol = new JobFunction();
        requiredRol.setCode("aCode");
        requiredRol.setDescription("aRole");
        req.setRequiredRol(requiredRol);
        Calendar startDate = new GregorianCalendar(2011, 6, 6);
        req.setStartDate(startDate);

        return req;
    }

    public static List<RequirementAssignmentRelationship> createNSizeConsecutiveList(final int n) {
        List<RequirementAssignmentRelationship> ret = new ArrayList<RequirementAssignmentRelationship>();
        int i;

        ret.add(createFullRAR());

        for (i = 1; i < n; i++) {
            RequirementAssignmentRelationship rar = createFullRAR();
            rar.setStartDate((Calendar) ret.get(i - 1).getEndDate().clone());
            rar.getStartDate().add(Calendar.DAY_OF_YEAR, 1);
            rar.setEndDate((Calendar) rar.getStartDate().clone());
            rar.getEndDate().add(Calendar.DAY_OF_YEAR, 300);

            ret.add(rar);
        }

        return ret;
    }

    public static List<RequirementAssignmentRelationship> createNSizeEqualButPercentageReqsList(final int n) {
        List<RequirementAssignmentRelationship> ret = new ArrayList<RequirementAssignmentRelationship>();
        int i;

        for (i = 0; i < n; i++) {
            RequirementAssignmentRelationship rar = createFullRAR();
            rar.setPorcentage((double) 100 / n);
            ret.add(rar);
        }

        return ret;
    }
}
